// import {myRequest} from "../../api/myRequest";
// import $actions from '../constant/actions'
import { myRequest } from '../../api/myRequest'
import { actionsMap } from '../../api/url'
const _ReportManage = 'ReportManage';
const $actions = actionsMap[_ReportManage]

const PageReport ={
	/**
	 * 添加信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	add(record) {
		return myRequest(_ReportManage,[{action: $actions.ADD, data: [record]}]);
	},

	/**
	 * 删除信息
	 * @param id
	 * @returns {Promise<*>}
	 */
	delete(id) {
		return myRequest(_ReportManage,[{action: $actions.DELETE,id:id}]);
	},

	/**
	 * 批量删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	batchDelete(filter) {
		return myRequest(_ReportManage,[{action: $actions.BATCH_DELETE, ...filter}]);
	},

	/**
	 * 批量删除信息
	 * @param ids
	 * @returns {Promise<*>}
	 */
	deleteByIds(ids) {
		return myRequest(_ReportManage,[{action: $actions.BATCH_DELETE, ids: ids}]);
	},

	/**
	 * 更新信息
	 * @param record
	 * @returns {Promise<*>}
	 */
	update(record) {
		let jsonValue = JSON.stringify(record.value);
		record["jsonValue"] =jsonValue;
		return myRequest(_ReportManage,[{action: $actions.UPDATE, data: [record]}]);
	},

	/**
	 * 查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	query(filter) {
		let recipient = [{action: $actions.QUERY,...filter}]
		return myRequest(_ReportManage,recipient);
	},
	/**
	 * 简单查询不包括属性或大字段信息
	 * @param filter
	 * @returns {Promise<*>}
	 */
	queryInfo(filter) {
		let recipient = [{action: $actions.QUERY_INFO,...filter}]
		return myRequest(_ReportManage,recipient);
	},
	/**
	 * 查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	queryByPage(pageNumber, pageSize, filter) {
		let recipient = [{action: $actions.QUERY_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize,...filter}]
		return myRequest(_ReportManage,recipient);
	},
	/**
	 * 查询列表
	 * @param recipient
	 * @returns {Promise<*>}
	 */
	queryInfoByPage(pageNumber, pageSize, filter) {
		let recipient = [{action: $actions.QUERY_BY_PAGE, pageNumber: pageNumber, pageSize: pageSize,...filter}]
		return myRequest(_ReportManage,recipient);
	}
}

export default {
	PageReport
};
